function getParameterValues(name) {
    if (location.search.length === 0) {
        return []
    }

    let qs = location.search.substr(1)
    let pairs = qs.split('&')
    let values = []
    for (let i = 0; i < pairs.length; i++) {
        let pair = pairs[i]
        let kv = pair.split('=')
        let key = decodeURIComponent(kv[0])
        let value = undefined
        if (kv.length > 1) {
            value = decodeURIComponent(kv[1])
        }

        if (name === key && value !== undefined) {
            values.push(value)
        }
    }

    return values
}

function getParameter(name) {
    return getParameterValues(name)[0]
}